package com.itheima.d7_generics_interface;

import java.util.ArrayList;


public class Impl2 implements OperateImpl<Student> {
    @Override
    public void printAll(ArrayList<Student> list) {
        int count1 = 0;
        int count2 = 0;
        for (int i = 0; i < list.size(); i++) {
            Student s = list.get(i);
            System.out.println(s.getName()+" "+  s.getSex()+ " "+ s.getScore());
            if(s.getSex().equals("男")){
                count1++;
            }else {
                count2++;
            }
        }
        System.out.println("男生个数是："+count1);
        System.out.println("女生个数是："+count2);
        System.out.println("======================");
    }

    @Override
    public void printEve(ArrayList<Student> list) {
        double sum = 0;
        double max = list.get(0).getScore();
        double min = list.get(0).getScore();
        for (int i = 0; i < list.size(); i++) {
            Student s = list.get(i);
            sum += s.getScore();
            if(max < s.getScore())  max = s.getScore();
            if(min > s.getScore())  min = s.getScore();

        }
        System.out.println("班级平均分是"+(sum - min -max) / (list.size() -2 ));
    }
}

